// 替换模板标签，生成文本
exports.formatFile = function (string, obj) {
  return string.replace(/<%=([\s\S]*?)%>/g, function () {
    if (arguments[1].trim() === "domain") {
      return obj[arguments[1].trim()];
    }
    if (arguments[1].trim() === "langs") {
      let langs = {};
      obj.language && obj.language.locales.map(lang => {
        let _lang = lang === 'hk' ? 'cn' : lang;
        langs[_lang] = require("../lang/" + lang + ".json");
      });
      let rtl = JSON.stringify(langs);
      return rtl;
    }
  });
}